package com.docking.heylo.web.controller;

import com.docking.heylo.dao.entity.Appointment;
import com.docking.heylo.service.IAppointmentService;
import com.docking.heylo.web.dto.OrderDto;
import com.docking.heylo.web.utils.ResultUtil;
import com.docking.heylo.web.vo.BaseVo;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * 订单管理
 *
 */
@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private IAppointmentService appointmentService;

    /***
     * 订单列表
     *
     * @return
     */
    @PostMapping("/list")
    public BaseVo list(@RequestBody OrderDto orderDto){
        PageInfo<Map<String, Object>> pageInfo = appointmentService.orderList(orderDto);
        return ResultUtil.success("成功", pageInfo);
    }

    /***
     * 订单详情
     *
     * @param orderDto
     * @return
     */
    @RequestMapping("/detail")
    public BaseVo detail(@RequestBody OrderDto orderDto){
        Map<String, Object> detail = appointmentService.orderDetail(orderDto.getId());
        return ResultUtil.success("成功", detail);
    }


    /***
     * 申诉订单处理
     *
     * @return
     */
    @PostMapping("/appealHandling")
    public BaseVo appealHandling(@RequestBody Appointment appointment){
        appointmentService.appealHandling(appointment);
        return ResultUtil.success("处理成功");
    }





}
